package com.draem0507.refactor;

/**
 * @title 解耦依赖
 * @desc
 * @atuh lwx
 * @createtime on 2015/11/14 12:12
 */
public class Day_12 {







    public class AnimalFeedingService1
    {
        public IFeederService FeederService ;

        public AnimalFeedingService1(IFeederService feederService)
        {
            FeederService = feederService;
        }

        private boolean FoodBowlEmpty ;

        public void Feed()
        {
            if (FoodBowlEmpty)
                FeederService.ReplenishFood();

            // more code to feed the animal
        }
    }

    public interface IFeederService
    {
        void ReplenishFood();
    }

    public class FeederService implements IFeederService
    {
        public void ReplenishFood()
        {
            Feeder.ReplenishFood();
        }
    }






    public class AnimalFeedingService
    {
        private boolean FoodBowlEmpty;

        public void Feed()
        {
            if (FoodBowlEmpty)
                Feeder.ReplenishFood();

            // more code to feed the animal
        }
    }

    public static class Feeder
    {
        public static void ReplenishFood()
        {
            // fill up bowl
        }
    }


}
